package com.yuan.pdf.util;

import java.util.Base64;

/**
 * @author siyuan
 * @date 2023/1/9 15:16
 */
public class ImgUtil {
    /**
     * base64转图片
     * @param data 内容源
     * @return
     */
    public static byte[] base64ToImg(String data){
        if (data.contains("data:")) {
            int start = data.indexOf(",");
            data = data.substring(start + 1);
        }
        final Base64.Decoder decoder = Base64.getDecoder();
        data = data.replaceAll("\r|\n", "");
        data = data.trim();
        return decoder.decode(data);
    }
}
